﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Thorn : Bullet
{
    float delay = 0;

  
    // Start is called before the first frame update
    void Start()
    {
        // GameObject temp = this.gameObject.transform.parent.gameObject;
        if (CapsuleCollider != null)
        {
            Physics.IgnoreCollision(CapsuleCollider, this.GetComponent<BoxCollider>(), true);
        }
        else if (CharCollider != null)
        {
            Physics.IgnoreCollision(CharCollider, this.GetComponent<BoxCollider>(), true);
        }
    }

    // Update is called once per frame
    void Update()
    {
        delay += Time.deltaTime;

        if (delay >= 3f)
        {
            Destroy(gameObject);
        }
    }

    public void OnTriggerEnter(Collider col)
    {

        if (col.gameObject.tag == "Enemy")
        {
            col.GetComponent<Enemy>().GetAttack(atk); //攻击指令
            bullletDestory();
        }
        else if (col.gameObject.tag == "Player")
        {
            col.GetComponent<Player>().GetAttack(atk);
            bullletDestory();
        }
        else if (col.gameObject.tag == "Wall")
        {
            bullletDestory();
        }
    }
}
